<template>
	<view class="borad_count" @click.stop="handleSpeak(text)">
		<image src="../static/img/config/broadcast.png" mode="scaleToFill" class="img_broad"></image>
		播报
	</view>
</template>

<script>
var synth;
export default {
	name: 'broad-cast',
	props: {
		text: {
			default: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3'
		},
		src: {
			default: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3'
		}
	},
	data() {
		return {
		};
	},
	methods: {
		handleSpeak(message) {
			console.log(2311);
			synth.play()
			synth.onPlay(() => {
				console.log('开始播放');
			});
		},
		handleStop() {}
	},
	created() {
		const initSpeak = () => {
			synth = uni.createInnerAudioContext();
			synth.src = this.src;
            console.log(synth);
			// msg.lang = 'zh-CN';
			// msg.volume = 2; // 声音音量：1
			// msg.rate = 1; // 语速：1
			// msg.pitch = 1; // 音高：1
		};
		initSpeak();
	}
};
</script>

<style scoped lang="scss">
.borad_count {
	width: 130upx;
	height: 40upx;
	background-color: #fce8e8;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 20upx;
	padding: 2upx 4upx;
	color: #f04a3e;
	font-size: 24upx;
}
.img_broad {
	width: 24upx;
	height: 22upx;
	margin-right: 10upx;
}
</style>
